/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controllers.filters;

import controllers.pipes.Reader2ValidatorPipe;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Sergio
 */
public final class FileReaderFilter extends Thread {

  private String FilePath;

  public String getFilePath() {
    return FilePath;
  }

  public void setFilePath(String FilePath) {
    this.FilePath = FilePath;
  }
  private String[] theArray = {/*
   * the array with the strings
   */};

  public FileReaderFilter() {
    super("FileReader");
    System.out.println("Startind thread: " + this);
  }

  @Override
  public void run() {
    try {
      Reader2ValidatorPipe theQueueInstance = Reader2ValidatorPipe.getInstance();
      FileInputStream fstream;
      fstream = new FileInputStream(FilePath);
      // Get the object of DataInputStream
      DataInputStream in = new DataInputStream(fstream);
      BufferedReader br = new BufferedReader(new InputStreamReader(in));
      String strLine;
      while ((strLine = br.readLine()) != null) {
        theQueueInstance.insertInto(strLine);//send to queue
//        Thread.sleep(500);
      }
    } catch (IOException ex) {
      Logger.getLogger(FileReaderFilter.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InterruptedException e) {
      System.out.println("Child interrupted.");
    }
    System.out.println("Exiting (producer).");
  }
}